using System;
using System.IO;
using System.Windows;
using MessageBox = System.Windows.MessageBox;
using MessageBoxButton = System.Windows.MessageBoxButton;
using MessageBoxImage = System.Windows.MessageBoxImage;

namespace WinFormsApp3
{
    public partial class App : System.Windows.Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            
            // Handle file associations - if a file was passed as an argument
            if (e.Args.Length > 0)
            {
                string filePath = e.Args[0];
                if (File.Exists(filePath))
                {
                    MainWindow mainWindow = new MainWindow(filePath);
                    mainWindow.Show();
                }
                else
                {
                    System.Windows.MessageBox.Show($"无法打开文件: {filePath}\n文件不存在。", 
                        "CooZip", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                    MainWindow mainWindow = new MainWindow();
                    mainWindow.Show();
                }
            }
            else
            {
                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
            }
        }
    }
}
